/*
 * @Author: zhangweixin 
 * @Date: 2018-11-26 22:12:23 
 * @Last Modified by: zhangweixin
 * @Last Modified time: 2018-11-26 22:14:20
 */
/**
 * Created by zzzz on 16/11/12.
 */
const UserAgent = {
    agents: {
        NORMAL: 'normal',
        WX: 'wx',
        APP: 'app'
    },

    isNormalAgent(agent) {
        return agent === this.agents.NORMAL
    },

    isWXAgent(agent) {
         return agent === this.agents.WX;
    },

    isAPPAgent(agent){
        return agent === this.agents.APP;
    },

    isApp() {
        return /xiyanghui-mobile/.test(navigator.userAgent);
    },

    isAppV2() {
        return /xiyanghui-mobile-v2/.test(navigator.userAgent);
    },

    setAgent(agent) {
        !!sessionStorage && window.sessionStorage.setItem('userAgent', agent);
    },

    getAgent() {
        return !!sessionStorage ? window.sessionStorage.getItem('userAgent') : '';
    },

    isWXBrowser() {
        return /MicroMessenger/.test(navigator.userAgent);
    },

    clearAgent() {
        !!sessionStorage && window.sessionStorage.removeItem('userAgent')
    }
};

export default UserAgent;
